package test_315;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 张杰
 * Date: 2022-03-15
 * Time: 9:08
 */
class OuterClass {
    public int data1 = 1;
    private int data2 = 2;
    public static int data3 = 3;

    //实例内部类：可以当做是外部类的一个实例的成员
    class InnerClass {
        public int data3 = 3;
        private int data4 = 4;
        public static final int data5 = 5;
        public InnerClass() {
            System.out.println("不带参数的内部类的构造方法！");
        }
        public void test() {
            System.out.println("InnerClass::test()");
        }
    }
    public void func1() {
        //static int a = 10;属于类的 不属于对象，因此不能在实例内部类以及方法里面定义静态变量
        System.out.println("OuterClass::func1()");
    }
}

public class TestDemo {
    //本地类
    /*public void func() {
        class Test {
            public int a;
        }
        //缺点：只能在当前方法中使用
    }*/

    public static void main(String[] args) {
        OuterClass outerClass = new OuterClass();
        outerClass.func1();

        OuterClass.InnerClass innerClass = outerClass.new InnerClass();
        innerClass.test();
    }
}





